package com.xian.demo.controller;


import com.xian.demo.model.User;
import com.xian.demo.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("index")
public class UserTestController {

    @Resource
    UserService userService;

    @RequestMapping("aa")
    public String sayHello(){
        System.out.println("22222222222222");
        return "hello";
    }

    @RequestMapping("b")
    public String getUser(@RequestParam("username") String username, HttpSession session){
        User user = userService.findByUsername(username);
        session.setAttribute("user",user);
        System.out.printf("USER:"+user);
        return "UserInfo";
    }
}
